Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

deNetUser.hpp

Go to the documentation of this file.
00001 ///////////////////////////////////////////////////////////////////////////////
00002 /// @file deNetUser.hpp
00003 ///
00004 /// @brief 
00005 ///
00006 /// @author trajar
00007 ///
00008 /// This file is the intellectual property of Novus Delta, LLC.. Usage of the
00009 /// contents of this file is subject to the Destiny3D Member License which
00010 /// can be found at http://www.destiny3d.com.  Any other usage is prohibited.
00011 ///
00012 /// This file is distributed "AS IS" without warranty of any kind.  Novus
00013 /// Delta, LLC. does not guarantee the fitness of the contents of this file
00014 /// for any particular purpose.
00015 ///
00016 /// Copyright (C) 2001-2003 Novus Delta, LLC. All Rights Reserved.
00017 ///
00018 /// <hr>
00019 ///                                 Change History
00020 /// <hr>
00021 ///
00022 /// @date Jun 2002
00023 /// @author trajar
00024 /// @remarks Creation
00025 ///
00026 ///////////////////////////////////////////////////////////////////////////////
00027 
00028 #ifndef _DENETUSER_HPP
00029 #define _DENETUSER_HPP
00030 
00031 #ifndef     _DENET_HPP
00032  #include   "deNet.hpp"
00033 #endif
00034 
00035 #ifndef     _DESYNCHOBJECT_HPP
00036  #include   "deSynchObject.hpp"
00037 #endif
00038 
00039 class deThread;
00040 class deNetMsg;
00041 class dePacket;
00042 class deConnection;
00043 
00044 typedef class DENET_API deNetUser
00045 {
00046 public:
00047 
00048     enum eNetStatus
00049     {
00050         STATUS_UNKNOWN = -1,
00051         STATUS_CREATED,
00052         STATUS_CONNECTED,
00053         STATUS_CLOSED,
00054         STATUS_DESTROYED,
00055     };
00056 
00057     enum eType
00058     {
00059         TYPE_UNKNOWN = 0,
00060         TYPE_MASTER_SERVER,
00061         TYPE_SLAVE_SERVER,
00062         TYPE_CLIENT,
00063         TYPE_PEER,
00064     };
00065 
00066     deNetUser(void);
00067     virtual ~deNetUser(void);
00068 
00069     eNetError           Init( int pType, DWORD dwFlags = NULL );
00070     eNetError           Destroy( DWORD dwFlags = NULL );
00071     eNetError           CloseConnection( DWORD dwFlags = NULL );
00072     virtual eNetError   SendToAll( WORD pMsgID, void * pData, DWORD pDataSize, DWORD dwFlags );
00073     eNetError           SendToUsers( WORD pMsgID, hNetUser * pUsers, DWORD pNumUsers, void * pData, DWORD pDataSize, DWORD dwFlags );
00074     eNetError           SendTo( WORD pNetMsgID, hNetUser hUser, void * pData, DWORD pDataSize, DWORD dwFlags );
00075     eNetError           HandleNetMsg( deNetMsg * pMsg );
00076     
00077     bool                IsNetIDUnique( hNetUser pUser );
00078     eNetError           ReleaseNetID( hNetUser pUser );
00079     hNetUser            GenerateNetID(void);
00080 
00081     void                AssignNetHandle( hNetUser handle);
00082     hNetUser            GetNetHandle(void);
00083     eNetStatus          GetNetStatus(void);
00084     eType               GetNetType(void);
00085     deNetAddress *      GetAddress(void);
00086     deSynchObject *     GetSynchObject(void);
00087 
00088 #ifdef DN_SESSION_TIME_INT64
00089     void                UpdateSessionTime( s64 pTime );
00090     s64                 GetSessionTime(void);
00091     s64                 GetApproxSessionTime(void);
00092     s64                 GetSessionTimeDelta(void);
00093 #else
00094     void                UpdateSessionTime( float pTime );
00095     float               GetSessionTime(void);
00096     float               GetApproxSessionTime(void);
00097     float               GetSessionTimeDelta(void);
00098 #endif
00099 
00100     virtual eNetError   OnTick( void );
00101     virtual deConnection *  GetConnectionByUser( hNetUser pUser );
00102 
00103 protected:
00104 
00105     //-------------------------------------------------------------------------------------
00106     // Override these methods in your deNetUser classes
00107     //-------------------------------------------------------------------------------------
00108     virtual eNetError   OnCustomMsg( deNetMsg * pMsg )                              = 0;
00109     virtual eNetError   OnNewConnection( deConnection * pConn )                     = 0;
00110     virtual eNetError   OnRemoveConnnection( deConnection * pConn )                 = 0;
00111 
00112     //-------------------------------------------------------------------------------------
00113     // Leave these alone, or call in a overidden method
00114     //-------------------------------------------------------------------------------------
00115     virtual eNetError   OnDestroy( DWORD dwFlags = NULL )                           = 0;
00116     virtual eNetError   OnInit( int pType, DWORD dwFlags = NULL )                   = 0;
00117     virtual eNetError   OnCloseConnection( DWORD dwFlags )                          = 0;
00118     virtual eNetError   OnConnectionLost( deConnectionLost * pLost )                = 0;
00119     virtual eNetError   OnConnectionRequest( deConnectionRequest * pRequest )       = 0;
00120     virtual eNetError   OnConnectionReply( deConnectionReply * pReply )             = 0;
00121     
00122     deConnection    *   m_Connection;
00123     eType               m_Type;
00124     eNetStatus          m_Status;
00125 
00126 #ifdef DN_SESSION_TIME_INT64
00127     s64                 m_SessionTime;
00128     s64                 m_SessionTimeDelta;
00129 #else
00130     float               m_SessionTime;
00131     float               m_SessionTimeDelta;
00132 #endif
00133         
00134 private:
00135 
00136     deSynchObject       m_SynchObject;
00137     deNetAddress        m_Address;
00138     hNetUser            m_NetHandle;
00139     deThread    *       m_ServiceThread;
00140     
00141 } deNetUser, *pdeNetUser;
00142 
00143 #endif

Generated on Mon Sep 12 19:58:32 2005 for Destiny3D by doxygen1.3-rc3